package com.lanxin.jet.controllers;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@PropertySource("classpath:config.properties")
public class SiteController {

    @Value("${jet.version}")
    private String jetVersion;

    @RequestMapping("/")
    public String index(ModelMap map) {
        map.put("info", "欢迎使用 Jet-CMS version: " + jetVersion);
        return "site/welcome";
    }

    @RequestMapping("/site/error/404")
    public String errorNotFound(ModelMap map) {
        map.put("title", "404. Not Found!");
        map.put("message", "您要访问的页面貌似不存在");
        map.put("version", "Jet-CMS " + jetVersion);
        return "site/error";
    }

    @RequestMapping("/site/error/405")
    public String errorMethodError(ModelMap map) {
        map.put("title", "405. Method Not Allowed!");
        map.put("message", "您访问的页面或者接口使用的姿势不对");
        map.put("version", "Jet-CMS " + jetVersion);
        return "site/error";
    }

    @RequestMapping("/site/error/500")
    public String errorServerError(ModelMap map) {
        map.put("title", "500. Oh Shit!");
        map.put("message", "我们遇到了一点点麻烦，等待处理");
        map.put("version", "Jet-CMS " + jetVersion);
        return "site/error";
    }

}